package com.foreveross.proxyip.application.impl.monitor;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.foreveross.proxyip.application.monitor.ChannelApplication;
import com.foreveross.proxyip.entity.ChannelEntity;
import com.foreveross.proxyip.monitor.domain.Channel;
import com.foreveross.proxyip.monitor.vo.ChannelEntityVO;
@Service
@Transactional
public class ChannelApplicationImpl implements ChannelApplication{

	@Override
	public List<ChannelEntityVO> getAllChannels() throws Exception {
		List<ChannelEntity> es=Channel.getAllChannels();
		List<ChannelEntityVO> vos=new ArrayList<ChannelEntityVO>();
		es=es!=null?es:new ArrayList<ChannelEntity>();
		if(!es.isEmpty()){
			for(ChannelEntity e:es){
				ChannelEntityVO vo=new ChannelEntityVO(e.getId(), e.getCode(), e.getCreateName(), e.getCreateTime(), 
						e.getCreator(), e.getFlgDeleted(), e.getIsValid(),
						e.getName(), e.getState(),e.getValidDefaultUrl(),e.getLastTime());
				vo.setSpeedGrade(e.getSpeedGrade());
				vo.setTimes(e.getTimes());
				vos.add(vo);
			}
		}
		return vos;
	}

}
